Method and system for managing heuristic properties

ABSTRACT

A computer implemented method, system and computer program product for managing heuristic properties for controlling an optimization transformation in a compiler or in other heuristically controlled software in a data processing system. A computer implemented method for controlling an optimization transformation in heuristically controlled software includes defining at least one heuristic property for controlling a behavior of an optimization transformation, and creating at least one heuristic property modifier for each desired change in the behavior of the optimization transformation. At least one of the at least one heuristic property is then modified using the at least one heuristic property modifier for achieving each desired change in the behavior of the optimization transformation.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates generally to the data processing field,and more particularly, to a computer implemented method, system andcomputer program product for managing heuristic properties forcontrolling an optimization transformation in a compiler or in otherheuristically controlled software in a data processing system.

2. Description of the Related Art

A compiler is a mechanism that translates a source code program that iswritten in a high-level, human-readable programming language, into anequivalent object code program that is in a machine language that can beexecuted by a computer. For each main source program and a number ofadditional source programs or subroutines, the compiler translates eachstatement in the programs into machine language equivalents. The outputof the compiler is a plurality of object code programs corresponding tothe input source code programs. A linker program then combines theobject code programs created by the compiler (that is, supplies theinterconnecting links between the program components) to create a singlemachine-executable program.

A number of compiler optimizations use heuristic values to controlbehavior, for example, a limit on the number of branches, a defaultunroll factor, etc. These heuristic values are usually tuned based onexperience gathered from compiling benchmarks and other programs. Insome cases, different heuristic values are chosen based on command-lineoptions, for example, a different default unroll factor may be chosendepending on the target processor.

In addition to default values for heuristic properties, somecommand-line modifiers, such as requesting the generated code to becompact (i.e., to favor smaller size over faster code), requiremodifying or resetting certain heuristic values, for example, limitingunroll factors.

A current method for having each optimization transformation logicallydetermine its defaults for heuristic properties has the advantage ofencapsulating a default value choice within the transformation code.Doing so, however, has the disadvantage that it becomes more difficultto control multiple heuristic properties from a central location. As aresult, any change in the policy of how these heuristic values arechosen for different cases needs to be handled every place in the codewhere these heuristic values are determined (and used). Addingfunctionality to the compiler that has a wide impact on multipleheuristic values, such as compact control or a new optimization level,can be quite cumbersome and error-prone due to the need to locate andupdate every heuristic property that might be affected by the newcontrol.

An alternative solution for heuristic values is to contain all heuristicvalues in a central database (or data structure, similar to the idea ofJava Properties—a class in the Java Development Kit for managingproperties, which can be stored, dumped to a file and read back; andSystem properties—a specific subset which can be overridden through the-D command line option), and then update/modify them as appropriate whennew optimization controls are added or modified. The disadvantage ofthis approach is the lack of encapsulation, that is, if any changes aremade to the logic of a transformation that requires changing thedefaults for its heuristic properties; the compiler writer needs to makesure that these changes are also reflected in the central database thatmanages these heuristics. A further disadvantage of a central databaseis that it adds overhead for accessing heuristic properties which may beaccessed frequently. Although these values can be cached, doing so addsan unnecessary complexity to the code and requires the compiler writerto be aware of the caching.

There is, accordingly, a need for a mechanism for more efficientlymanaging heuristic properties for controlling an optimizationtransformation in a compiler or in other heuristically controlledsoftware in a data processing system.

SUMMARY OF THE INVENTION

The present invention provides a computer implemented method, system andcomputer program product for managing heuristic properties forcontrolling an optimization transformation in a compiler or in otherheuristically controlled software in a data processing system. Acomputer implemented method for controlling an optimizationtransformation in heuristically controlled software includes defining atleast one heuristic property for controlling a behavior of anoptimization transformation, and creating at least one heuristicproperty modifier for each desired change in the behavior of theoptimization transformation. At least one of the at least one heuristicproperty is then modified using the at least one heuristic propertymodifier for achieving each desired change in the behavior of theoptimization transformation.

BRIEF DESCRIPTION OF THE DRAWINGS

The novel features believed characteristic of the invention are setforth in the appended claims. The invention itself, however, as well asa preferred mode of use, further objectives and advantages thereof, willbest be understood by reference to the following detailed description ofan illustrative embodiment when read in conjunction with theaccompanying drawings, wherein:

FIG. 1 is a pictorial representation of a data processing system inwhich aspects of the present invention may be implemented;

FIG. 2 is a block diagram depicting a data processing system in whichaspects of the present invention may be implemented;

FIG. 3 is a block diagram that schematically illustrates a compilersystem in which aspects of the present invention may be implemented;

FIG. 4 is a flowchart that illustrates a method for controllingoptimization transformations in heuristically controlled software in adata processing system according to an exemplary embodiment of thepresent invention; and

FIG. 5 is a flowchart that illustrates a method for defining a heuristicproperty for controlling an optimization transformation in heuristicallycontrolled software according to an exemplary embodiment of the presentinvention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

FIGS. 1-2 are provided as exemplary diagrams of data processingenvironments in which embodiments of the present invention may beimplemented. It should be appreciated that FIGS. 1-2 are only exemplaryand are not intended to assert or imply any limitation with regard tothe environments in which aspects or embodiments of the presentinvention may be implemented. Many modifications to the depictedenvironments may be made without departing from the spirit and scope ofthe present invention.

With reference now to the figures and in particular with reference toFIG. 1, a pictorial representation of a data processing system isdepicted in which the aspects of the present invention may beimplemented. A computer 100 is depicted which includes system unit 102,video display terminal 104, keyboard 106, storage devices 108, which mayinclude floppy drives and other types of permanent and removable storagemedia, and mouse 110. Additional input devices may be included withpersonal computer 100, such as, for example, a joystick, touchpad, touchscreen, trackball, microphone, and the like. Computer 100 can beimplemented using any suitable computer, such as an IBM eServer computeror IntelliStation computer, which are products of International BusinessMachines Corporation, located in Armonk, New York. Although the depictedrepresentation shows a computer, other embodiments of the presentinvention may be implemented in other types of data processing systems,such as a network computer. Computer 100 also preferably includes agraphical user interface (GUI) that may be implemented by means ofsystems software residing in computer readable media in operation withincomputer 100.

With reference now to FIG. 2, a block diagram of a data processingsystem is depicted in which aspects of the present invention may beimplemented. Data processing system 200 is an example of a computer,such as computer 100 in FIG. 1, in which code or instructionsimplementing the processes of the present invention may be located. Inthe depicted example, data processing system 200 employs a hubarchitecture including a north bridge and memory controller hub (MCH)202 and a south bridge and input/output (I/O) controller hub (ICH) 204.Processor 206, main memory 208, and graphics processor 210 are connectedto north bridge and memory controller hub 202. Graphics processor 210may be connected to the MCH through an accelerated graphics port (AGP),for example.

In the depicted example, local area network (LAN) adapter 212 connectsto south bridge and I/O controller hub 204 and audio adapter 216,keyboard and mouse adapter 220, modem 222, read only memory (ROM) 224,hard disk drive (HDD) 226, CD-ROM drive 230, universal serial bus (USB)ports and other communications ports 232, and PCI/PCIe devices 234connect to south bridge and I/O controller hub 204 through bus 238 andbus 240. PCI/PCIe devices may include, for example, Ethernet adapters,add-in cards, and PC cards for notebook computers. PCI uses a card buscontroller, while PCIe does not. ROM 224 may be, for example, a flashbinary input/output system (BIOS). Hard disk drive 226 and CD-ROM drive230 may use, for example, an integrated drive electronics (IDE) orserial advanced technology attachment (SATA) interface. A super I/O(SIO) device 236 may be connected to south bridge and I/O controller hub204.

An operating system runs on processor 206 and coordinates and providescontrol of various components within data processing system 200 in FIG.2. The operating system may be a commercially available operating systemsuch as Microsoft® Windows® XP (Microsoft and Windows are trademarks ofMicrosoft Corporation in the United States, other countries, or both).An object oriented programming system, such as the Java™ programmingsystem, may run in conjunction with the operating system and providescalls to the operating system from Java programs or applicationsexecuting on data processing system 200 (Java is a trademark of SunMicrosystems, Inc. in the United States, other countries, or both).

Instructions for the operating system, the object-oriented programmingsystem, and applications or programs are located on storage devices,such as hard disk drive 226, and may be loaded into main memory 208 forexecution by processor 206. The processes of the present invention areperformed by processor 206 using computer implemented instructions,which may be located in a memory such as, for example, main memory 208,read only memory 224, or in one or more peripheral devices.

Those of ordinary skill in the art will appreciate that the hardware inFIGS. 1-2 may vary depending on the implementation. Other internalhardware or peripheral devices, such as flash memory, equivalentnon-volatile memory, or optical disk drives and the like, may be used inaddition to or in place of the hardware depicted in FIGS. 1-2. Also, theprocesses of the present invention may be applied to a multiprocessordata processing system.

In some illustrative examples, data processing system 200 may be apersonal digital assistant (PDA), which is configured with flash memoryto provide non-volatile memory for storing operating system files and/oruser-generated data. A bus system may be comprised of one or more buses,such as a system bus, an I/O bus and a PCI bus. Of course the bus systemmay be implemented using any type of communications fabric orarchitecture that provides for a transfer of data between differentcomponents or devices attached to the fabric or architecture. Acommunications unit may include one or more devices used to transmit andreceive data, such as a modem or a network adapter. A memory may be, forexample, main memory 208 or a cache such as found in north bridge andmemory controller hub 202. A processing unit may include one or moreprocessors or CPUs. The depicted examples in FIGS. 1-2 andabove-described examples are not meant to imply architecturallimitations. For example, data processing system 200 also may be atablet computer, laptop computer, or telephone device in addition totaking the form of a PDA.

The present invention provides a computer implemented method, system andcomputer program product for managing heuristic properties forcontrolling an optimization transformation in a compiler or in otherheuristically controlled software in a data processing system. Accordingto an exemplary embodiment of the present invention, “heuristicmodifiers” are applied to sets of heuristic properties in order toadjust the heuristic properties.

FIG. 3 is a block diagram that schematically illustrates a compilersystem within which aspects of the present invention may be implemented.The system is generally designated by reference number 300, and, asillustrated, a user, such as a programmer, may define a source codeprogram 302 that is written in a high-level, human-readable language.Once source code program 302 is defined, compiler 304 translates thesource code program into an equivalent object code program 306 that isin a machine language such that it can be executed by a computer.Compiler 304 may be implemented in a data processing system, such asdata processing system 200 illustrated in FIG. 2.

The present invention provides the advantageous features of bothencapsulation and central management, as well as low overhead. Inaddition, the invention provides coarse-grain and fine-grain controlover heuristic values without it being necessary to modify the compilersource, along with built-in logic to do “full-scale modifications ” ofheuristic properties based on “modification logic”. For example,according to an exemplary embodiment of the present invention, whenapplying a compact control modification, all relevant heuristic valuesare modified to satisfy the constraints implied by “compact”. Thesefull-scale modifications can also be applied on top of one another,contributing to the simplicity of implementing different behaviorsexpected from the compiler according to user requirements (given throughcommand-line options). For example, the “compact” control and the“favor-compile-speed” control can be combined on top of one another toprovide the expected behavior. This combination is done through applyingthe appropriate ‘full-scale modifiers’, also referred to herein as‘Heuristic Context Modifiers’, one after the other on the centrallymanaged heuristic context (the ‘database’).

According to an exemplary embodiment of the present invention, eachoptimization transformation is assigned an abbreviation, i.e., a uniquetext string without spaces that will represent the transformation. Forexample, the unroll-and-jam transformation is represented by theabbreviation “unrolljam”, the Index-Set Splitting transformation isrepresented by the abbreviation “ixsplit”, and so on.

For each transformation, a set of heuristic properties controlling the“behavior” of the transformation is defined; and an abbreviation isassigned to each property. The abbreviations are preferably chosen to begeneral enough such that if a number of optimization transformationsshare the same heuristic property, a single abbreviation can be used forthat heuristic property. Separate instances for each controlledtransformation are still used so that they can be independentlycontrolled. The common abbreviation, however, enables a quick and easyway of controlling all the transformations that depend on that heuristicproperty. For example, the ‘Use Register Pressure’ heuristic property isassigned the “regpr” abbreviation. A number of transformations areaffected by this heuristic property, including Unroll-and-Jam andPredictive Commoning.

For each instance of a heuristic property, the following components aredefined:

1. Abbreviation—As indicated above, a short name, with no spaces, thatis used to represent the heuristic property. This component is hereafterreferred to as <abbrev>.

2. Transformation Abbreviation—The abbreviation of the optimizationtransformation in which this instance of a heuristic property isdefined, and which the heuristic property controls. This component ishereafter referred to as <transabbrev>.

3. Default value—This is the default value for the heuristic property.That is, if there are no modifications applied to the heuristicproperty, this will be the value of the heuristic property.

4. Range—The range of permitted values allowed for this property. Forexample, for a logical (Boolean) heuristic property, the range of valuesmay be {Off, On}, or {False, True}, or {0, 1}. Range is defined as aunion of sub-ranges. That is, a Range of a heuristic property can bedefined to be {1-4, 8-15}, which would mean that the permitted valuesfor this property are any values from 1 to 4 or from 8 to 15. Therefore,2 and 9 would be permitted values in this Range, but 7 and 19 would notbe permitted values (It is assumed that numerical ranges are given as asequence of 1 or more sub-ranges, in order, and that the sub-ranges donot overlap).

5. Description—A short textual description of the heuristic property ora key to a multilingual catalogue that contains descriptions of theheuristic property in the set of native languages supported by theproduct.

A Heuristic Context is a data structure where heuristic propertyinstances get registered. Each optimization transformation has a directreference to the heuristic properties it defines; however, when aheuristic property is defined, it gets automatically registered in someHeuristic Context. The Heuristic Context allows centralized access toall the heuristic properties registered in that context. HeuristicProperty instances in the Heuristic Context are generally accessed usinga key composed of “<transabbrev>.<abbrev>” of the property. For example,to access the ‘Use Register Pressure’ heuristic property of theUnroll-and-jam transformation, the key “unrolljam.regpr” would be used.

A Heuristic Context Modifier is a set of (<key>,<operator>,<value>)triplets, where <operator> is one of {“=”, “<”, “>”}, and <key>and<value> are strings with no spaces in them. For example, the followingHeuristic Context Modifier {(“unrolljam.regpr”,=,“false”),(“ixsplit.maxibranch”,<,3)}, modifies the ‘Use Register Pressure’heuristic property of the Unroll-and-jam transformation to “false”, andadds a temporary constraint for the ‘Maximum Inductive Branch’ heuristicproperty of the “Index-Set Splitting” transformation to be less than3(see description below regarding the use of temporary constraints).

A Heuristic Context can register multiple Heuristic Context Modifiers,which are applied in the order in which they were registered. Theapplication of any modifiers is done at the time a heuristic propertygets registered in the context. This allows Heuristic Context Modifiersto be registered before the transformations actually begin, or beforeany of the heuristic properties get registered in the Heuristic Context.This also allows the modification of heuristic property values to beprioritized, based on the source of the modification (as will beexplained hereinafter, multiple “sources” for modifications are allowed:the transformation itself, the heuristic context modifiers, and externalfiles or command-line options).

An additional flexibility is added when modifiers are used that refer tokeys that contain only the <abbrev> of a heuristic property. Forexample, the Heuristic Context Modifier {(“regpr”,=,“false”)} will causethe ‘Use Register Pressure’ heuristic property of any transformationthat defines it to have the value “false”. On the other hand, due to theprioritization of modifiers, the use of register pressure can be veryeasily turned off everywhere, except for the transformation where it isdesired to be used. For example, the Heuristic Context Modifier{(“regpr”,=,“false”), (“unrolljam.regpr”,=,“true”)}will turn off use ofregister pressure in every transformation except for Unroll-and-jam.

Adding a simple parsing component to the Heuristic Context Modifier, andallowing constructing of a Heuristic Context Modifier instance using aninput string, considerably simplifies the definition of such modifiers.For example, the Heuristic Context Modifier from the example above couldbe defined using the string “regpr=false:unrolljam.regpr=true”.

Adding the parser adds a great deal more flexibility. For example, allthe heuristic properties and their values in a given context can bedumped to a file, along with ‘comments’ (the ‘#’ character is defined asthe beginning of a comment that ends at the end of the line). Thecomments can contain the description text for each heuristic property,its default value, and a range of allowed values. A simple text editorcan then be used to modify the property values in the file, and feedthat file back into the construction of the desired Heuristic ContextModifier. This flexibility can also be taken a step further by allowingfor a command line option that can take a Heuristic Context Modifierstring as its value, that is applied last on any heuristic property.

In the parser, ‘:’ or white space is used as a separator betweendefinitions of heuristic property values. The example above uses ‘:’since it emulates the way these options can be given at thecommand-line. This simplifies the process of tuning the compiler byusing the command- line to tune certain heuristic properties, without itbeing required to rebuild the compiler every time, and then pasting thatcommand-line as a string into the construction of a Heuristic ContextModifier.

As indicated above, a Heuristic Context Modifier contains a set of(<key>,<operator>,<value>) triplets. The use of the assignment operator‘=’ was demonstrated above. Namely, a modifier may contain theassignment of a new value for a property (note that the value has to bein the range of permitted values defined for that property).

The ‘<’ (lesser-than) operator is used to set a “temporary constraint”on the value of a Heuristic Property (note: temporary constraints applyonly to numerical Heuristic Properties). That is, at the time themodifier is applied, the value of the Heuristic Property has to be inthe permitted range defined for that property and satisfy thatconstraint, if possible. For example, the Heuristic Property“ixsplit.maxibranch”, which was mentioned above, may have a defaultvalue of 4, and a permitted value range of 1-16. The modifier to beapplied “ixsplit.maxibranch<3” requires that the value of that propertywill be at most 2. Since before applying the modifier, the HeuristicProperty temporarily contains the value 4 (which is the default and islarger than the maximum value requested), the Heuristic Property“ixsplit.maxibranch” would be set with the value 2.

If, however, the default value for the Heuristic Property“ixsplit.maxibranch” is set to be 1(or if the value was set to 1 by someprevious Heuristic Context Modifier), then applying the modifier“ixsplit.maxibranch<3” would not affect the value of that property sincethe current value already satisfies the constraint.

The ‘>’ (greater-than) operator is used in a similar way (to request atemporary lower bound on the value of the property, instead of atemporary upper bound). Referring back to the above example with the“ixsplit.maxibranch” Heuristic Property containing the temporary valueof 4 (with a permitted range of 1-16), if the modifier“ixsplit.maxibranch>20” is applied, the Heuristic Property“ixsplit.maxibranch” would be set with the value 16, which is apermitted value (i.e., in the permitted value range for the property)that is closest to the requested value.

It should be clear that if the permitted value range of a HeuristicProperty, for example, “a.b”, is multi-range e.g., 1-4, 8-16), and the“a.b” heuristic property has the current value of, say 3, then atemporary constraint “a.b>6” would cause setting “a.b” to the value 8.

The temporary constraint operators (i.e., operators ‘<’ and ‘>’) aredefined to be more “loose” than the assignment operator (i.e., theoperator ‘=’), since it is desirable to be able to apply them on top ofone another and retain as much of the previous setting as possible. Thatis, if a value of a property is set to some small value, any constraintthat sets a lower bound would try to keep that value small (i.e., if thevalue was smaller than the lower bound, set it to the lower bound). Ifthe value was large and a lower bound is set which is smaller, thatlower bound would have no effect on the value (i.e., that value wouldremain as large as it was set by default or by the previous modifier).

The approach of using Heuristic Context Modifiers enables “heuristicaspects” to be defined for the compiler. That is, a set of behaviors fortransformations (determined by values or temporary constraints) thatwould determine a general desired behavior of the compiler. An exampleof a heuristic aspect is “compactness”. Generally, compactness requiresoptimization transformations to generate code that is “compact”, i.e.,the generated code should prefer code size over code speed. This mayrequire turning some optimization off, and limiting the behavior ofother transformations. According to an exemplary embodiment of thepresent invention, “compactness” is defined as a set of valuemodifications for the Heuristic Properties defined by the differenttransformations. Temporary constraint modifiers are also used on some ofthe heuristic properties. A “compactness” aspect is then defined as aHeuristic Context Modifier that is registered with the Heuristic Contextwhen the user of the compiler specifies the compact option. Theresulting values of the Heuristic Properties registered by theoptimization transformations would cause the compiler's behavior change,i.e., to generate compact code.

Another example of a “heuristic aspect” is “favor-compile-speed”.Generally, “favor-compile-speed” requires optimization transformationsto favor fast compile-time over performance of the generated code. Thatmeans that certain transformations may need to be turned off, and otherswould need to be limited (or partially limited) to enable them to befaster (sacrificing potential run-time performance gains). The“favor-compile-speed” aspect is then defined as a Heuristic ContextModifier that is registered with the Heuristic Context when a user ofthe compiler requires a faster compile-time.

The design of the framework for managing Heuristic Properties enablesHeuristic Context Modifiers to be applied on top of one another. Thismeans that they can be registered with a Heuristic Context in an orderof preference before any optimization transformations are applied, andhave them applied to the Heuristic Properties as they get registered bythe transformations. This enables, for example, a request to a user ofthe compiler for both the “compactness” aspect and the“favor-compile-speed” aspect to be easily supported, since theseHeuristic Context Modifiers would simply be applied on top of oneanother with as little contradiction between them as possible.

In order to further clarify this aspect of the present invention, thefollowing demonstrates what happens to specific Heuristic Propertiesduring such an application, and how these values affect the compiler.

Initially, the order in which the modifiers are applied is determined.Since the last modifier is applied last, this means that it has thehigher priority. Therefore, the “compactness” modifier is defined to beapplied last (since compactness is favored over compile-speed if bothare requested).

Assume that the “favor-compile-speed” turns off, say, “Loop Fusion”(turning off of transformations is achieved by having eachtransformation define an “enabled” heuristic property which it checksbefore executing. Therefore, if any of the “enabled” properties is setoff, transformations would be turned off). The “favor-compile-speed” isactually more aggressive (and uses another feature of the framework forthat). It turns off all transformations using the general “enabled”abbrev to do that, and then turns on only a subset of transformations,e.g., “unrolljam.enabled=true”. That way, when new transformations areadded to the compiler, they will be off by default for the“favor-compile-speed” aspect, and they can be enabled if it is chosen todo so (i.e., if they are fast enough).

Also assume that “favor-compile-speed” turns off use of RegisterPressure (“regpr=false”) for all transformations, and sets anupper-bound temporary constraint on the ‘Maximal Inductive Branches’heuristic property in the Index Set Splitting transformation(“ixsplit.maxibranch<3”).

The “compactness” aspect may set some properties (e.g.,“fusion.guarded=false”) for Loop Fusion, however, with the“favor-compile-speed” applied before it has turned off loop fusion, thesetting of this property will have no effect when these two modifiersare combined, since “compactness” does not specifically turn on loopfusion.

The “compactness” aspect may set “ixsplit.maxibranch<2”, whichdetermines a smaller upper-bound for the ‘Maximal Inductive Branches’heuristic property in the Index Set Splitting transformation. Whenapplied on-top of the “favor-compile-speed” aspect, this would cause theheuristic value of “ixsplit.maxibranch” to be set to 1. Since temporaryconstraints are being used here instead of absolute values, it wouldmake no difference if the “compactness” aspect was applied before the“favor-compile-speed” aspect rather than after it since applying“ixsplit.maxibranch<2” before “ixsplit.maxibranch<3” would still resultin “ixsplit.maxibranch” being set to 1.

On the other hand, applying a “more-loop-fusion” aspect (if one werecreated), would probably specifically turn on loop fusion (if it wasoff), and other sub-features of loop-fusion, and also enable moreIndex-Set splitting (i.e., increase the lower-bound on“ixsplit.maxibranch”, to enable taking the resulting loops apart intoseparate nests that do not contain inductive branches (which are easierto optimize)). Although this would contradict the “compactness” and“favor-compile-speed” on the general level, these modifications would bespecifically applied to Loop Fusion and Index-Set splitting, thus notaffecting any of the modifications done to the other transformations.The result is that the general behavior implied by either “compactness”or “favor-compile-speed” (or both) would still be there, except for thetwo transformations that were affected by the additional modifier.

As can be seen from the above description, the framework according toexemplary embodiments of the present invention enables extremelyflexible control of heuristic properties. The nature of heuristic valuesis such that they are usually not absolute (i.e., different aspects mayhave different impacts on these values), and some tuning effort isneeded to set the defaults for heuristic properties, however, thecomplexity of tuning different values for different user options anddifferent combinations of options may be too great. The framework of thepresent invention allows defining “heuristic aspects” that correspond touser options, and combining different aspects (due to the use oftemporary constraints, among other things) to create the desiredcombined behaviors.

The following description provides a summary of the mechanisms forimplementing a framework for managing heuristic properties in a compileror in other heuristically controlled software in a data processingsystem according to exemplary embodiments of the present invention.

HeuristicContext

The Heuristic Context contains a hash table of heuristic properties.Every heuristic property that gets registered in the context has areference to it added to this hash table, using its ‘key’ (i.e., thestring composed of “<transabbrev>.<abbrev>”) as the key to the hashtable.

The Heuristic Context also contains an ordered list ofHeuristicContextModifier references. The process of registering aHeuristicContextModifier in a HeuristicContext appends a reference tothe HeuristicContextModifier into that ordered list.

The heuristic context modifier is simply a set of triplets (key,operator, value) with not much logic behind it, except for it beingmanaged as a hash table with the ‘key’ field of each triplet being usedto access entries in the table. The actual logic happens when aheuristic property gets registered in the HeuristicContext.

Registering a Heuristic Property

For each Heuristic Property that is being registered:

-   -   An entry in the hash table of heuristic properties is added with        the “<transabbrev>.<abbrev>” combined string used as the key,        and the Heuristic Property object reference as the data.    -   The value of the Heuristic Property is set to its designated        default value (which is part of the definition of a Heuristic        Property in the framework).    -   For each HeuristiccontextModifier in the order in which they are        registered with the HeuristicContext (the command-line option        for defining heuristic modifications is appended as the last        modifier):    -   If the HeuristicContextModifier contains a triplet (key,        operator, value) where key is “<transabbrev>.<abbrev>”, then        -   -   Call SetHeuristicPropertyValue with a reference to the                Heuristic Property, and the operator and the value from                the triplet.

        -   Else, if the HeuristicContextModifier contains a triplet            (key, operator, value) where key is “<abbrev>”, then            -   Call SetHeuristicPropertyValue with a reference to the                Heuristic Property, and the operator and the value from                the triplet.

Procedure SetHeuristicPropertyValue (ref,op,val)

Input:

-   -   ref—A reference to a Heuristic Property    -   op—An operator (one of ‘<’, ‘=’, ‘>’)    -   val—A value to be used for modifying the Heuristic Property

Output:

-   -   May modify the value of ref.value

Algorithm:

-   -   If operator is ‘=’, then        -   Set ref.value to val    -   Else if operator is ‘<’ and ref.value is larger than or equal to        val, then        -   Set ref.value to ClosestsLowerInRange (ref, val)    -   Else if operator is ‘>’ and ref.value is smaller or equal to        val, then        -   Set ref.value to ClosestsHigherInReange (ref, val)

Function ClosestsLowerInRange (ref, val)

Input:

-   -   ref—A reference to a Heuristic Property    -   val—A value to be used for modifying the Heuristic Property

Output:

-   -   Largest “permitted” value for Heuristic Property ref that is        still smaller than val (if one exists, or the smallest permitted        value in ref.Range otherwise)

Algorithm:

-   -   Set closest_range to nil    -   For each sub-range [lower-bound, upper-bound] in ref.Range from        first to last and while lower-bound is less than val        -   Set closest_range to [lower-bound, upper-bound]    -   If closest_range is some [lower-bound, upper-bound] (i.e., not        nil) then        -   If upper-bound is greater than or equal to val, then return            the result ofval-1        -   Else, return upper-bound    -   Else,        -   Let [lower-bound, upper-bound] be the first sub-range in            ref.Range        -   Return lower-bound

Function ClosestsHigherInRange (ref.val)

Input:

-   -   ref—A reference to a Heuristic Property    -   val—A value to be used for modifying the Heuristic Property

Output:

-   -   Smallest “permitted” value for Heuristic Property ref that is        still larger than val (if one exists, or the largest permitted        value in ref.Range otherwise)

Algorithm:

-   -   Set closest_range to nil    -   For each sub-range [lower-bound, upper-bound] in ref.Range from        last to first and while upper-bound is greater than val        -   Set closest_range to [lower-bound, upper-bound]    -   If closest_range is some [lower-bound, upper-bound] (i.e., not        nil), then        -   If lower-bound is smaller than or equal to val, then return            the result of val+1    -   Else,        -   Let [lower-bound, upper-bound] be the last sub-range in            ref.Range        -   Return upper-bound.

FIG. 4 is a flowchart that illustrates a method for controllingoptimization transformations in heuristically controlled software in adata processing system according to an exemplary embodiment of thepresent invention. The method is generally designated by referencenumber 400, and begins by identifying each optimization transformationto be performed (Step 402). At least one heuristic property is thendefined for controlling a behavior of each optimization transformationto be performed (Step 404).

FIG. 5 is a flowchart that illustrates Step 404 in greater detail. Inparticular, FIG. 5 is a flowchart that illustrates a method for defininga heuristic property for controlling an optimization transformation inheuristically controlled software according to an exemplary embodimentof the present invention. The method is generally designated byreference number 500, and includes, for each heuristic property that isdefined, setting an abbreviation and a description that identifies theheuristic property (Steps 502 and 504), setting a default value for theheuristic property (Step 506), and setting a range of permitted valuesallowed for the heuristic property (Step 508). The range of permittedvalues may comprise a set of sub-ranges given as a sequence ofsub-ranges, which are in ascending numerical order, and which do notoverlap.

Returning to FIG. 4, after the heuristic properties for controlling thebehavior of each optimization transformation are defined in Step 404, aset of heuristic property modifiers are created for each definedbehavior change of the heuristically controlled software (Step 406). Theheuristic modifiers are then combined together to form a heuristiccontext modifier that can be used to change a specific aspect of thebehavior (or the entire behavior) of the heuristically controlledsoftware (Step 408), and the heuristic properties that need to bemodified to achieve a desired behavior of the optimization are thenmodified to complete the process (Step 410). Steps 406-410 may berepeated as often as needed for each behavioral change that is to beadded.

The present invention thus provides a computer implemented method,system and computer program product for managing heuristic propertiesfor controlling an optimization transformation in a compiler or in otherheuristically controlled software in a data processing system. Acomputer implemented method for controlling an optimizationtransformation in heuristically controlled software includes defining atleast one heuristic property for controlling a behavior of anoptimization transformation, and creating at least one heuristicproperty modifier for each desired change in the behavior of theoptimization transformation. At least one of the at least one heuristicproperty is then modified using the at least one heuristic propertymodifier for achieving each desired change in the behavior of theoptimization transformation.

The invention can take the form of an entirely software embodiment or anembodiment containing both hardware and software elements. In apreferred embodiment, the invention is implemented in software, whichincludes but is not limited to firmware, resident software, microcode,etc.

Furthermore, the invention can take the form of a computer programproduct accessible from (or comprising) a computer-usable orcomputer-readable medium providing computer-usable or computer-readableprogram code for use by or in connection with a computer or anyinstruction execution system. For the purposes of this description, acomputer-usable or computer readable medium can be any tangibleapparatus that can contain, store, communicate, propagate, or transportthe program for use by or in connection with the instruction executionsystem, apparatus, or device.

The medium can be an electronic, magnetic, optical, electromagnetic,infrared, or semiconductor system (or apparatus or device) or apropagation medium. Examples of a computer-readable medium include asemiconductor or solid state memory, magnetic tape, a removable computerdiskette, a random access memory (RAM), a read-only memory (ROM), arigid magnetic disk and an optical disk. Current examples of opticaldisks include compact disk - read only memory (CD-ROM), compact disk -read/write (CD-R/W) and DVD.

A data processing system suitable for storing and/or executing programcode will include at least one processor coupled directly or indirectlyto memory elements through a system bus. The memory elements can includelocal memory employed during actual execution of the program code, bulkstorage, and cache memories which provide temporary storage of at leastsome program code in order to reduce the number of times code must beretrieved from bulk storage during execution.

Input/output or I/O devices (including but not limited to keyboards,displays, pointing devices, etc.) can be coupled to the system eitherdirectly or through intervening I/O controllers.

Network adapters may also be coupled to the system to enable the dataprocessing system to become coupled to other data processing systems orremote printers or storage devices through intervening private or publicnetworks. Modems, cable modem and Ethernet cards are just a few of thecurrently available types of network adapters.

The description of the present invention has been presented for purposesof illustration and description, and is not intended to be exhaustive orlimited to the invention in the form disclosed. Many modifications andvariations will be apparent to those of ordinary skill in the art. Theembodiment was chosen and described in order to best explain theprinciples of the invention, the practical application, and to enableothers of ordinary skill in the art to understand the invention forvarious embodiments with various modifications as are suited to theparticular use contemplated.

1. A computer implemented method for controlling an optimizationtransformation in heuristically controlled software, comprising:defining at least one heuristic property for controlling a behavior ofan optimization transformation; creating at least one heuristic propertymodifier for each desired change in the behavior of the optimizationtransformation; and modifying at least one of the at least one heuristicproperty using the at least one heuristic property modifier forachieving each desired change in the behavior of the optimizationtransformation.
 2. The computer implemented method according to claim 1,wherein defining at least one heuristic property for controlling abehavior of an optimization transformation comprises: identifying eachat least one heuristic property; and setting a range of permitted valuesfor each at least one heuristic property.
 3. The computer implementedmethod according to claim 2, wherein identifying each at least oneheuristic property comprises: providing an abbreviation representingeach at least one heuristic property.
 4. The computer implemented methodaccording to claim 3, wherein identifying each at least one heuristicproperty further comprises: providing a textual description of each atleast one heuristic property.
 5. The computer implemented methodaccording to claim 2, wherein setting a range of permitted values foreach at least one heuristic property, comprises: setting a plurality ofsub-ranges of permitted values for at least one of each at least oneheuristic property.
 6. The computer implemented method according toclaim 2, wherein defining at least one heuristic property forcontrolling a behavior of an optimization transformation furthercomprises: setting a default value for each at least one heuristicproperty.
 7. The computer implemented method according to claim 1,wherein creating at least one heuristic property modifier for eachdesired change in the behavior of the optimization transformation,comprises, for each at least one heuristic property modifier: forming anidentifier representing an associated heuristic property; forming anoperator for identifying a modification to be made to the associatedheuristic property; and forming a value for the modification.
 8. Thecomputer implemented method according to claim 7, wherein forming anoperator for identifying a modification to be made to the associatedheuristic property comprises: forming an assignment operator forassigning a new value to the associated heuristic property.
 9. Thecomputer implemented method according to claim 7, wherein forming anoperator for identifying a modification to be made to the associatedheuristic property comprises: forming a temporary constraint operatorfor setting a temporary constraint on a value of the associatedheuristic property, wherein the temporary constraint operator comprisesone of a greater than temporary constraint operator and a lesser thantemporary constraint operator.
 10. The computer implemented methodaccording to claim 1, wherein at least one heuristic propertyabbreviation refers to a plurality of heuristic properties, and whereinthe computer implemented method further comprises: setting a first valuefor all of the plurality of heuristic properties that are referenced bythe at least one heuristic property abbreviation; and setting valuesdifferent from the first value for a specific subset of the plurality ofheuristic properties that includes at least one of the plurality ofheuristic properties, wherein each at least one heuristic propertyincluded in the subset of the plurality of heuristic properties isreferenced with both a transformation abbreviation that represents anoptimization transformation in which the heuristic property is definedand the heuristic property abbreviation.
 11. The computer implementedmethod according to claim 1, wherein creating at least one heuristicproperty modifier for each desired change in the behavior of theoptimization transformation comprises: creating a plurality of heuristicproperty modifiers for at least one desired change in the behavior ofthe optimization transformation; and wherein modifying at least one ofthe at least one heuristic property using the at least one heuristicproperty modifier for achieving each desired change in the behavior ofthe optimization transformation, comprises: modifying one of the atleast one heuristic property using the plurality of heuristic propertymodifiers one on top of another in order of priority.
 12. The computerimplemented method according to claim 1, and further comprising:combining each at least one heuristic property modifier into a heuristiccontext modifier for achieving desired changes in the behavior of theoptimization transformation.
 13. The computer implemented methodaccording to claim 1, wherein the heuristically controlled softwarecomprises a compiler.
 14. A computer program product, comprising: acomputer usable medium having computer usable program code forcontrolling an optimization transformation in heuristically controlledsoftware, the computer program product comprising: computer usableprogram code configured for defining at least one heuristic property forcontrolling a behavior of an optimization transformation; computerusable program code configured for creating at least one heuristicproperty modifier for each desired change in the behavior of theoptimization transformation; and computer usable program code configuredfor modifying at least one of the at least one heuristic property usingthe at least one heuristic property modifier for achieving each desiredchange in the behavior of the optimization transformation.
 15. Thecomputer program product according to claim 14, wherein the computerusable program code configured for defining at least one heuristicproperty for controlling a behavior of an optimization transformationcomprises: computer usable program code configured for identifying eachat least one heuristic property; and computer usable program codeconfigured for setting a range of permitted values for each at least oneheuristic property.
 16. The computer program product according to claim15, wherein the computer usable program code configured for identifyingeach at least one heuristic property comprises: computer usable programcode configured for providing an abbreviation representing each at leastone heuristic property.
 17. The computer program product according toclaim 16, wherein the computer usable program code configured foridentifying each at least one heuristic property further comprises:computer usable program code configured for providing a textualdescription of each at least one heuristic property.
 18. The computerprogram product according to claim 15, wherein the computer usableprogram code configured for setting a range of permitted values for eachat least one heuristic property, comprises: computer usable program codeconfigured for setting a plurality of sub-ranges of permitted values forat least one of each at least one heuristic property.
 19. The computerprogram product according to claim 15, wherein the computer usableprogram code configured for defining at least one heuristic property forcontrolling a behavior of an optimization transformation furthercomprises: computer usable program code configured for setting a defaultvalue for each at least one heuristic property.
 20. The computer programproduct according to claim 14, wherein the computer usable program codeconfigured for creating at least one heuristic property modifier foreach desired change in the behavior of the optimization transformation,comprises, for each at least one heuristic property modifier: computerusable program code configured for forming an identifier representing anassociated heuristic property; computer usable program code configuredfor forming an operator for identifying a modification to be made to theassociated heuristic property; and computer usable program codeconfigured for forming a value for the modification.
 21. The computerprogram product according to claim 20, wherein the computer usableprogram code configured for forming an operator for identifying amodification to be made to the associated heuristic property comprises:computer usable program code configured for forming an assignmentoperator for assigning a new value to the associated heuristic property.22. The computer program product according to claim 20, wherein thecomputer usable program code configured for forming an operator foridentifying a modification to be made to the associated heuristicproperty comprises: computer usable program code configured for forminga temporary constraint operator for setting a temporary constraint on avalue of the associated heuristic property, wherein the temporaryconstraint operator comprises one of a greater than temporary constraintoperator and a lesser than temporary constraint operator.
 23. Thecomputer program product according to claim 14, wherein at least oneheuristic property abbreviation refers to a plurality of heuristicproperties, and wherein the computer program product further comprises:computer usable program code configured for setting a first value forall of the plurality of heuristic properties that are referenced by theat least one heuristic property abbreviation; and computer usableprogram code configured for setting values different from the firstvalue for a specific subset of the plurality of heuristic propertiesthat includes at least one of the plurality of heuristic properties,wherein each at least one heuristic property included in the subset ofthe plurality of heuristic properties is referenced with both atransformation abbreviation that represents an optimizationtransformation in which the heuristic property is defined and theheuristic property abbreviation.
 24. The computer program productaccording to claim 14, wherein the computer usable program codeconfigured for creating at least one heuristic property modifier foreach desired change in the behavior of the optimization transformationcomprises: computer usable program code configured for creating aplurality of heuristic property modifiers for at least one desiredchange in the behavior of the optimization transformation; and whereinthe computer usable program code configured for modifying at least oneof the at least one heuristic property using the at least one heuristicproperty modifier for achieving each desired change in the behavior ofthe optimization transformation, comprises: computer usable program codeconfigured for modifying one of the at least one heuristic propertyusing the plurality of heuristic property modifiers one on top ofanother in order of priority.
 25. The computer program product accordingto claim 14, and further comprising: computer usable program codeconfigured for combining each at least one heuristic property modifierinto a heuristic context modifier for achieving desired changes in thebehavior of the optimization transformation.
 26. The computer programproduct according to claim 14, wherein the heuristically controlledsoftware comprises a compiler.
 27. A system for controlling anoptimization transformation in heuristically controlled software in adata processing system, comprising: a mechanism for defining at leastone heuristic property for controlling a behavior of an optimizationtransformation; a mechanism for creating at least one heuristic propertymodifier for each desired change in the behavior of the optimizationtransformation; and a mechanism for modifying at least one of the atleast one heuristic property using the at least one heuristic propertymodifier for achieving each desired change in the behavior of theoptimization transformation.
 28. The system according to claim 27,wherein the mechanism for defining at least one heuristic property forcontrolling a behavior of an optimization transformation comprises: aheuristic property identifier for identifying each at least oneheuristic property; and a range of permitted values for each at leastone heuristic property.
 29. The system according to claim 28, whereinthe heuristic property identifier comprises an abbreviation representingeach at least one heuristic property.
 30. The system according to claim29, wherein the heuristic property identifier further comprises atextual description of each at least one heuristic property.
 31. Thesystem according to claim 28, wherein the mechanism for defining atleast one heuristic property for controlling a behavior of anoptimization transformation further comprises a default value for eachat least one heuristic property.
 32. The system according to claim 27,wherein the mechanism for creating at least one heuristic propertymodifier for each desired change in the behavior of the optimizationtransformation, comprises, for each at least one heuristic propertymodifier: an identifier representing an associated heuristic property;an operator for identifying a modification to be made to the associatedheuristic property; and a value for the modification.
 33. The systemaccording to claim 32, wherein the operator for identifying amodification to be made to the associated heuristic property comprisesone of an assignment operator for assigning a new value to theassociated heuristic property, and a temporary constraint operator forsetting a temporary constraint on a value of the associated heuristicproperty.
 34. The system according to claim 27, and further comprising:a heuristic context modifier combining each at least one heuristicproperty modifier for achieving desired changes in the behavior of theoptimization transformation.
 35. The system according to claim 27,wherein the heuristically controlled software comprises a compiler.